﻿using System.Collections.Generic;
using System.Text;
using System.Web.Mvc;
using EPiServer.Core;
using System.Web.Mvc.Html;

namespace EPiMVC.Html
{
    public static class PageListHelpers
    {
        public static string PageLinks(this HtmlHelper html, IEnumerable<PageData> pages)
        {
            StringBuilder result = new StringBuilder();
            result.AppendLine("<ul>");
            foreach (PageData pageData in pages)
            {
                result.AppendLine("<li>");
                TagBuilder tag = new TagBuilder("a");
                tag.MergeAttribute("href", pageData.LinkURL);
                result.AppendLine(tag.ToString());
                result.AppendLine("</li>");
            }
            result.AppendLine("</ul>");
            return result.ToString();
        }
    }
}
